-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.7] Zoom in/out to correct location #66618
Conversation
Size Change: +291 B (+0.02%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
Flaky tests detected in 0b4d86d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11784136135
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this in a good enough state for 6.7.1 now. Let's get at least a couple others to review this since it isn't exactly a small change to fix the bug.
Is this really something we need in a point release? It seems a bit risky tbh. |
But this works well when I use the dedicated zoom-out button 👍 cool! |
$scroll-top: var(--wp-block-editor-iframe-zoom-out-scroll-top, 0); | ||
$scroll-top-next: var(--wp-block-editor-iframe-zoom-out-scroll-top-next, 0); | ||
|
||
position: fixed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you comment on why fixed positioning is needed on the html
element to make this work?
// ); | ||
// iframeDocument.documentElement.style.removeProperty( | ||
// '--wp-block-editor-iframe-zoom-out-scale-container-width' | ||
// ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine. So we always want to calculate these variables I guess. Unmounting is not needed then because when the iframe unmounts these attributes are automatically removed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so you're pre-calculating the final scroll position at the start of the animation, then you animate it in CSS in translate
as an offset, and finally when the transition ends, you swap that out for a real scroll position? That's brilliant!
There's some similarities with the block moving animation, but there we set the scroll position continuously, which is probably not so smooth in this case. See:
preserveScrollPosition(); |
It would be nice if we could move all this logic to a separate hook outside the iframe component.
Super nit pick: when I exit zoom out and I'm all the way at the bottom, it seems the scroll position doesn't stay at the bottom. But that's fine if it's too difficult. |
Btw, I approved this for trunk, I am not sure if this should be merged into 6.7. I'll leave that up to the release leads. I didn't see that this was targeting the 6.7 immediately. |
Pinging @cbravobernal who is leading 6.7.1 from Core Editor side. |
Maybe rebase this onto trunk and then we can cherry pick if needed? |
I have a |
We had some code to do this at one point, but after implementing it, we realized that it also felt off to zoom in to the bottom, as you may be working with the central part of the canvas. Either way it feels a little off, so we opted to go with the simpler method. |
@ellatrix I believe we only preserve the ratio when you start from zoom out. I think without zoom out engaged the sidebars have always caused reflow. |
Let's include it in 6.7.2 |
Where is the PR for trunk? |
|
Fixes #65884
Also fixes a minor bug where setting the scroll position was still delayed even when there was no animation due to reduced motion settings.
What?
Maintain the visible content of the editor canvas when zooming in/out.
Why?
It's disorienting to zoom in/out and lose your frame of reference.
How?
When changing scale (zoom in/out):
It will always attempt to scale to the center unless we are at the top of the canvas. In which case, it will scale to keep the top of the canvas visible.
Known bugs
Testing Instructions
Zooming from Top
Screen.Recording.2024-11-06.at.2.38.52.PM.mov
Zooming from below Top
Screen.Recording.2024-11-06.at.2.39.17.PM.mov
Open/close sidebar scaling animations
Try to break it :)
Testing Instructions for Keyboard
Screenshots or screencast
Before
Screen.Recording.2024-11-06.at.3.29.26.PM.mov
After
Screen.Recording.2024-11-06.at.12.27.31.PM.mov